package com.bdqn.factory;

import com.bdqn.dao.PetDao;
import com.bdqn.dao.impl.PetDaoMySQLImpl;
import com.bdqn.dao.impl.PetDaoOracleImpl;

/**
 * PetDaoFactory 宠物DAO实例工厂
 *
 * @author LILIBO
 * @since 2025/1/17
 */
public class PetDaoFactory {

    /**
     * 默认的实例名称（简称）
     */
    public static String beanName = "MySQL";

    /**
     * 获取宠物DAO实例
     *
     * @return
     */
    public static PetDao getInstance() {
        return new PetDaoMySQLImpl();
    }

    /**
     * 获取宠物DAO实例
     *
     * @return
     */
    public static PetDao getInstance(String beanName) {
        PetDao petDao = null;
        switch (beanName) {
            case "MySQL":
                petDao = new PetDaoMySQLImpl();
                break;
            case "Oracle":
                petDao = new PetDaoOracleImpl();
                break;
            default:
                throw new RuntimeException("未找到 " + beanName + " 实例对象");
        }
        return petDao;
    }

}
